package cn.zdxiang.jmjetpackmvvm

import android.os.Bundle
import androidx.fragment.app.Fragment
import cn.zdxiang.base.base.BaseVmFragment
import cn.zdxiang.base.base.DataBindingConfig
import kotlinx.android.synthetic.main.main_fragment.*

/**
 * @author       Jm
 * @date         2020/7/20 18:02
 * @description
 */
class MainFragment : BaseVmFragment() {

    private var mFragments: MutableList<Fragment> = arrayListOf()

    init {
        mFragments.apply {
            add(HomeFragment.newInstance())
            add(HomeFragment.newInstance())
            add(HomeFragment.newInstance())
            add(HomeFragment.newInstance())
            add(HomeFragment.newInstance())
        }
    }

    override fun getDataBindingConfig(): DataBindingConfig? {
        return DataBindingConfig(R.layout.main_fragment)
    }

    override fun init(savedInstanceState: Bundle?) {
        vpHome.adapter = FragmentStateAdapter(mActivity, mFragments)
        vpHome.offscreenPageLimit = mFragments.size
    }
}